#!/bin/bash

# cdiff
# File ID: 45f660ac-fa5f-11dd-9262-0001805bf4b1
# Latskapen lenge leve. Kjører en svn eller cvs diff og stripper bort alle
# ukjente filer.

git log HEAD..HEAD >/dev/null 2>&1
if [ "$?" = "0" ]; then
    git diff "$@"
    exit
fi

if [ -d .svn/. ]; then
    if [ "$1" = "-s" ]; then
        shift
        svn diff $* 2>/dev/null | grep -v '^\? ' | egrep '^[+\-]' | less -S
    else
        svn diff $* 2>/dev/null | grep -v '^\? ' | less -S
    fi
elif [ -d CVS/. ]; then
    if [ "$1" = "-s" ]; then
        shift
        cvs -n diff -u $* 2>/dev/null | grep -v '^\? ' | egrep '^[+\-]' | less -S
    else
        cvs -n diff -u $* 2>/dev/null | grep -v '^\? ' | less -S
    fi
else
    git diff --color "$@"
fi
